<template>
    <div class="detail">
        <detail-header :sightName='sightName'></detail-header>
        <detail-banner :bannerImg='bannerImg' :gallaryImgs='gallaryImgs'></detail-banner>
        <div class="content">
          <detail-list :list='list'></detail-list>
        </div>
    </div>
</template>
<script>
import axios from 'axios'
import DetailBanner from './components/Banner'
import DetailHeader from './components/Header'
import DetailList from './components/List'
export default {
  name: 'Detail',
  data () {
    return {
      sightName: '',
      bannerImg: '',
      gallaryImgs: [],
      list: []
    }
  },
  mounted () {
    this.getDetailInfo()
  },
  components: {
    DetailBanner,
    DetailHeader,
    DetailList
  },
  methods: {
    getDetailInfo () {
      const id = this.$route.params.id
      localStorage.lastId = id
      axios.get('/api/detail.json?id=' + id)
        .then(this.getDetailInfoSucc)
    },
    getDetailInfoSucc (res) {
      // console.log(res)
      res = res.data
      if (res.ret && res.data) {
        this.list = res.data.categoryList
        this.sightName = res.data.sightName
        this.bannerImg = res.data.bannerImg
        this.gallaryImgs = res.data.gallaryImgs
      }
    }
  },
  activated () {
    // 先不用这个，用exclude
    // const id = this.$route.params.id
    // if (id !== localStorage.id) {
    //   localStorage.id = id
    //   this.getDetailInfo()
    // }
  }
}
</script>
<style lang="stylus" scoped>
.detail
    // overflow :scroll
    // position :absolute
    // top:0
    // left:0
    // right:0
    // bottom:0
    .content
        height:15rem
</style>
